<?php

class Gallery_Block_Subcategories extends Kernel_Block
{

	public $active;

    /**
     * Return template data.
     *
     * @return  array
     */
    public function getData()
    {
        $query = '
                SELECT
                       `id`,
                       `parent_id`,
                       `name`,
                       `url`,
                       IF(`url` = "' . Application::getRequest()->uri(1) . '", 1, 0) `active`
                  FROM
                       `photo_categories`
              ORDER BY
                       `position`
            ';
        return array('entries' => Kernel_Util_Tree::children(database::fetchAll($query), $this->active));
    }

}